
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%-- 导入面包屑 --%>
<jsp:include page="../common/nav.jsp"></jsp:include>

<div class="wrapper wrapper-content animated fadeInRight">

    <%-- 导入提示信息框 --%>
    <c:if test="${hint!=null&&hint!=''}">
   		<jsp:include page="../common/alert/alert.jsp">
   			<jsp:param value="${hint}" name="alertType"/>
   			<jsp:param value="${alertMessage}" name="alertMessage"/>
   		</jsp:include>
    </c:if>
    
    <c:if test="${requestScope.status=='N'}">
	    <div class="alert alert-warning alert-dismissable">
			<button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>当前期初数据未生效，请点击“期初生效”按钮
		</div>
	</c:if>
	
	<%-- 导入查询框 --%>
	<jsp:include page="search/gLBalanceSearch.jsp"></jsp:include>
	
	<div class="row">
		<div class="col-lg-12">
			<div class="ibox ">
		        <div class="ibox-title">
		            <h4>期初余额列表</h4>
		            <div class="ibox-tools">
		            	<c:if test="${requestScope.actualNum==0}">
		            		<c:if test="${requestScope.status=='N'}">
		                		<button id="addButton" class="btn btn-success btn-sm" type="button"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">新增科目期初</span></button>
		                	</c:if>
		                	<c:if test="${requestScope.status=='N'}">
		                		<button id="finishButton" class="btn btn-info btn-sm" type="button"><span class="bold">期初生效</span></button>
		                	</c:if>
		                	<c:if test="${requestScope.status=='Y'}">
		                		<button id="unfinishButton" class="btn btn-danger btn-sm" type="button"><span class="bold">期初失效</span></button>
		                	</c:if>
		                </c:if>
		                <button id="searchButton" class="btn btn-default btn-sm btn-notcontrol" type="button"><i class="fa fa-search"></i>&nbsp;&nbsp;展开查询</button>
		            </div>
		        </div>
				<div class="ibox-content border-bottom" style="padding-bottom: 0px;">
					<div class="table-responsive">
						<table class="table table-striped table-hover table-bordered border-top">
							<thead>
								<tr>
									<%-- 
									<th></th>
									--%>
									<th width="5%">序号</th>
									<th>编码</th>
									<th>分类账簿</th>
									<th>会计科目结构</th>
									<th>会计科目描述</th>
									<th>币种</th>
									<th>会计期间</th>
									<th>期初借方</th>
									<th>期初贷方</th>
									<th>状态</th>
									<th width="10%">操作</th>
								</tr>
							</thead>
							<tbody>
							
							    <c:forEach items="${requestScope.gLBalanceList}" var="data" varStatus="status">
								<tr>
									<td>${status.count}</td>
									<td>${data.balanceCode}</td>
									<td>${requestScope.glLedger.ledgerName}</td>
									<td>${data.subjectDesc}</td>
									<td>${data.subjectDescTitle}</td>
									<td>${requestScope.currencyTypeMap[data.currencyCode]}</td>
									<td>${data.periodName}</td>
									<td>${data.endDr}</td>
									<td>${data.endCr}</td>
									<td>
										<c:choose>
										   <c:when test="${data.status=='Y'}">
										       <span class="label label-primary">有效</span>
										   </c:when>
										   <c:otherwise>
										       <span class="label label-danger">无效</span>
										   </c:otherwise>
										</c:choose>
									</td>
									<td>
										<div class="btn-group">
											<button class="btn-white btn btn-xs btn-notcontrol" onclick="editData(${data.balanceId})"><i class="fa fa-edit"></i>&nbsp;编辑</button>&nbsp;
											<c:if test="${requestScope.actualNum==0}">
												<c:if test="${requestScope.status=='N'}">
												<button class="btn-white btn btn-xs" onclick="deleteData(${data.balanceId})"><i class="fa fa-trash"></i>&nbsp;删除</button>
												</c:if>
											</c:if>
										</div>
									</td>
								</tr>
								</c:forEach>
								
							</tbody>
							<tfoot>
							    <%-- 导入页码 --%>
								<jsp:include page="../common/pages.jsp"></jsp:include>
							</tfoot>
						</table>
					</div>

				</div>
			</div>
		</div>
		
	</div>
</div>

<script>
	$(document).ready(function() {
		$("#addButton").click(function(){
		    window.location.href="web/gLBalance/getGLBalance";
		});
		
		$("#finishButton").click(function(){
			redragonJS.confirm("确认期初生效？", function(){
				window.location.href="web/gLBalance/updateBeginBalanceStatus?ledgerCode=master&status=Y";
			});
		});
		
		$("#unfinishButton").click(function(){
			redragonJS.confirm("确认期初失效？", function(){
				window.location.href="web/gLBalance/updateBeginBalanceStatus?ledgerCode=master&status=N";
			});
		});
		
		$("#searchButton").click(function(){
		    if($("#searchDiv").css("display")=="none"){
		        $("#searchDiv").show();
		        $("#searchButton").html('<i class="fa fa-search"></i>&nbsp;&nbsp;关闭查询');
		        $("#searchButton").addClass("btn-outline btn-warning");
		        $("#searchButton").blur();
		    }else{
		        $("#searchDiv").hide();
		        $("#searchButton").html('<i class="fa fa-search"></i>&nbsp;&nbsp;展开查询');
		        $("#searchButton").removeClass("btn-outline btn-warning");
		        $("#searchButton").blur();
		    }
		});
	});
	
	function editData(id){
		window.location.href="web/gLBalance/getGLBalance?balanceId="+id;
	}
	
	function deleteData(id) {
		redragonJS.confirm("确认删除数据？", function(){
			window.location.href="web/gLBalance/deleteGLBalance?balanceId="+id;
		});
	}
</script>       